package com.flycat.common.util;

import com.flycat.dto.query.CommonQuery;
import org.apache.commons.lang3.StringUtils;
import tk.mybatis.mapper.entity.Condition;

/**
 * @Author yalei.chen
 * @Date 2017/9/29
 * @Since JDK 1.8
 */
public class QueryUtils {

    public static void setSortCondition(Condition condition, String sortby,String ordered){

        if(StringUtils.isNoneBlank(sortby)){

            StringBuffer orderByClause = new StringBuffer(sortby);
            if(StringUtils.isNoneBlank(ordered) && "desc".equalsIgnoreCase(ordered)){
                orderByClause.append(" desc");
            }
            condition.setOrderByClause(orderByClause.toString());
        }
    }
}
